import Vue from 'vue'
import VueRouter from 'vue-router'
// import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'name',
    component: () => import('@/views/login')
  },

  {
    path: '/',
    name: 'layout',
    component:()=>import('@/views/layout'),
    children:[
      {
      path:'',  //默认子路由，只能有一个
      name:'home',
      component:()=>import('@/views/home')

    },
      {
        path:'/qa',
        name:'qa',
        component:()=>import('@/views/qa')

      },
      {
        path:'/edit',
        name:'edit',
        component:()=>import('@/views/edit')

      },
      {
        path:'/my',
        name:'my',
        component:()=>import('@/views/my')

      },


    ]
  },

  {
    path: '/search',
    name: 'search',
    component:()=> import('@/views/search')
  },


  {
    path: '/article/:articleId',
    name: 'article',
    component:()=> import('@/views/article'),
    props:true, //开启props传参，说白了就是把路由参数映射到组件中props中
  },

  {
    path: '/addArticle',
    name: 'addArticle',
    component:()=> import('@/views/edit/addArticle/addArticle'),
  },

]

const router = new VueRouter({
  routes
})

export default router
